#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 9e6 + 10, mod = 1e4;

string s;
LL q[N];
int tt = -1;

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> s;
    // cout << s;

    LL num = 0;

    bool last = false;
    for(int i = 0; i < s.length(); i ++){
        if(s[i] >= '0' && s[i] <= '9'){
            num = num * 10 + (s[i] - '0');
        }else if(s[i] == '+'){
          
                
            q[++tt] = num % mod;
            num = 0;

            if(last){
                LL a = q[tt--], b = q[tt--];
                LL c = a * b % mod;
                q[++tt] = c;
                last = false;
            }
            
        }else{
           
            // cout << num << '\n';
            q[++tt] = num % mod;
            num = 0;

            if(last){
                LL a = q[tt--], b = q[tt--];
                LL c = b * a % mod;
                q[++tt] = c;
                last = false;
            }

            
            last = true;
            
        }

    }

    if(num){
        q[++ tt] = num;

        if(last){
            LL a = q[tt--], b = q[tt --];
            LL c = a * b % mod;
            q[++tt] = c;
            last = false;
        }
    }
    LL res = 0;
    for(int i = 0; i <= tt; i ++){
     //   cout << q[i] << " ";
        res += q[i];
        res %= mod;
    }   

    cout << res % mod << '\n';

    return 0;
}